<?php
error_reporting(0);
include_once '../comm/config.php';
include '../comm/checkpostandget.php';
include 'check.php';
include_once '../comm/wjt.php';

$current=$_GET['cur']?$_GET['cur']:'infoset';

$sql="select * from ".$BIAOTOU."user where Id=".$_SESSION["dduserid"]."";
$rs = mysql_query($sql);
while ($row = mysql_fetch_array($rs)){
	 $password=$row["ddpassword"]; 
	 $zfb=$row["zfb"]; 
	 $tbusername=$row["tbusername"]; 
	 $email=$row["email"]; 
	 $mobile=$row["mobile"]; 
	 $qq=$row["qq"]; 
}	

$sql="select ortherwebname from ".$BIAOTOU."apilogin where dduserid=".$_SESSION["dduserid"];
$rs = mysql_query($sql);
while ($row = mysql_fetch_array($rs)){
	 $ortherwebname_arr[]=$row['ortherwebname'];
}


$tag="center";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>账户设置 - 用户中心</title>
<link href="../css/usercss.css" rel="stylesheet" type="text/css">
<link href="../template/<?=MOBAN?>/css/common.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/jquery.js"></script>
<style type="text/css">
<!--
.STYLE4 {color: #FF3300; font-weight: bold; }
.STYLE5 {color: #0099FF}
-->
</style>
<script language="javascript" type="text/javascript">	
function getLength(str) {
    var len = str.length;
    var reLen = 0;
    for (var i = 0; i < len; i++) {        
        if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
            // 全角    
            reLen += 2;
        } else {
            reLen++;
        }
    }
    return reLen;    
} 

function checkoldpass()
{
	var password=document.getElementById("oldpassword").value;
    	if(getLength(password)<6 || getLength(password)>50)
		{
			document.getElementById("ckoldpass").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
			return false;
		}
		else
		{
			document.getElementById("ckoldpass").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码填写原正确</font>';
			return true;
		}
}    

function checkpass()
{
	var password=document.getElementById("password").value;
    	if((getLength(password)<6 && getLength(password)>0) || getLength(password)>20)
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
			return false;
		}
		else
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码填写正确</font>';
			return true;
		}
}    

function checkpass2()
{
	var password2=document.getElementById("password2").value;
    	if((getLength(password2)<6 && getLength(password2)>0) || getLength(password2)>20)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
			return false;
		}
		else if (document.getElementById("password").value!=document.getElementById("password2").value)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>两次密码输入不一致！</font>';
			return false;
		}
		else
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码再次确认正确</font>';
			return true;
		}
}

function checkemail()
{
		var str = document.getElementById("email").value;    
        if(str.length!=0)
		{    
			reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;    
			if(!reg.test(str))
			{    
				document.getElementById("ckemail").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>电子邮件格式填写错误，请检查</font>';
				return false;
			}
			else
			{
				document.getElementById("ckemail").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>电子邮件格式正确</font>';
				return true;
			}
		}
		else
		{
				document.getElementById("ckemail").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>请填写电子邮件</font>';
				return false;
		}
} 
function checkzfb()
{
		var str = document.getElementById("zfb").value;    
        if(str.length!=0)
		{    
			document.getElementById("ckzfb").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>支付宝填写正确</font>';
			return true;
		}
		else
		{
			document.getElementById("ckzfb").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>请填写支付宝</font>';
			return false;
		}
}
function checkname()
{
		var str = document.getElementById("tbusername").value;    
        if(str.length==0)
		{    
			document.getElementById("cktbusername").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>请填写真实姓名，提现时核对用</font>';
			return false;
		}
		else{
			document.getElementById("cktbusername").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>姓名已填写</font>';
		    return true;
		}
		
} 
function checkall()
{
	if(checkoldpass()&&checkpass()&&checkpass2()&&checkemail()&&checkzfb()&&checkname())
	{
		return true;
		
	}
	else
	{
		return false;
		
	}
}
$(function(){
    $('.title ul li a').click(function(){
	    $('.title ul li a').removeClass('current');
		$(this).addClass('current');
		$('#infoset,#binding').hide();
		$('#'+$(this).attr('value')).show();
	});
})
</script>
</head>

<body id="info">
<?php
include("../template/".MOBAN."/header.tpl.php");
?>
<?php
include("../template/".MOBAN."/nav.tpl.php");
?>
<div id="main">
<?php
include("left.php");
?>
<div class="contain" style="height:450px">
  <h2 class="left_nav1">我的账户设置</h2>
    <div class="order">
    <div class="title" style="width:445px; margin-bottom:15px; height:30px">
            <ul>
              <li><a value="infoset" style="MARGIN-LEFT: 10px" <?php if($current=='infoset'){?> class="current" <?php }?>>个人信息设置</a></li>
              <li><a value="binding" style="MARGIN-LEFT: 10px" <?php if($current=='binding'){?> class="current" <?php }?>>账号通设置</a></li>
            </ul>
          </div>
    <div class="content" style="font-size:12px; height:320px;">
						<form id="infoset" name="form1" action="info_save.php" method="post" onsubmit="return checkall()" <?php if($current=='binding'){?> style="display:none" <?php }?>>
                        <table width="568" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td height="33" align="right"  class="bigtext"><font color="#FF0000">*</font> 原密码：</td>
                            <td height="33" align="left">&nbsp;&nbsp;
                            <input name="oldpassword" id="oldpassword" type="password" class="input1" onblur="checkoldpass();" maxlength="50"  style="width:200px;" /></td>
                            <td height="33" align="left" class="bigtext" id="ckoldpass">填写旧密码</td>
                          </tr>
                          <tr>
                            <td height="33" align="right"  class="bigtext">新密码：</td>
                            <td height="33" align="left">&nbsp;&nbsp;
                            <input name="password" id="password" type="password" class="input1" onblur="checkpass();"  maxlength="20"  style="width:200px;" /></td>
                            <td height="33" align="left" class="bigtext" id="ckpass">填写新密码，不修改的话保持空白</td>
                          </tr>
                          <tr>
                            <td height="33" align="right"  class="bigtext">确认密码：</td>
                            <td height="33" align="left">&nbsp;&nbsp;
                            <input name="password2" id="password2" type="password" class="input1" onblur="checkpass2();"  maxlength="20"  style="width:200px;" /></td>
                            <td height="33" align="left" class="bigtext" id="ckpass2">重复新密码，不修改的话保持空白</td>
                          </tr>
                          <tr>
                            <td height="33" align="right"  class="bigtext">电子邮件：</td>
                            <td width="235" height="33" align="left">&nbsp;&nbsp;
                            <input name="email" id="email" type="text" class="input1" onblur="checkemail();" value="<?php echo $email?>" maxlength="50" style="width:200px;" /> <font color="#FF0000">*</font></td>
                            <td width="238" height="33" align="left" class="bigtext" id="ckemail"></td>
                          </tr>
                          <tr>
                            <td height="33" align="right"  class="bigtext">支付宝账号：</td>
                            <td height="33" align="left">&nbsp;&nbsp;
                            <input name="zfb" id="zfb" type="text" class="input1" onblur="checkzfb();" value="<?php echo $zfb?>" maxlength="50" <?php if ($zfb!=""){ echo "disabled='disabled'";}?> style="width:200px;" /> <font color="#FF0000">*</font></td>
                            <td height="33" align="left" class="bigtext" id="ckzfb">第一次设置后无法更改或找管理员更改</td>
                          </tr>
						  <tr>
                            <td height="33" align="right"  class="bigtext">真实姓名：</td>
                            <td height="33" align="left">&nbsp;&nbsp;
                            <input name="tbusername" id="tbusername" type="text" class="input1" onblur="checkname();" value="<?php echo $tbusername?>" maxlength="50" <?php if ($tbusername!=""){ echo "disabled='disabled'";}?> style="width:200px;" /></td>
                            <td height="33" align="left" class="bigtext" id="cktbusername">提现转账时核对用，填写后无法修改</td>
                          </tr>
                          <tr>
                            <td height="33" align="right"  class="bigtext">手机号码：</td>
                            <td height="33" align="left">&nbsp;&nbsp;
                            <input name="mobile" id="mobile" type="text" class="input1"  value="<?php echo $mobile?>" maxlength="50" style="width:200px;" /></td>
                            <td height="33" align="left" class="bigtext" id="ckzfb"></td>
                          </tr>
                          <tr>
                            <td height="33" align="right"  class="bigtext">联系QQ：</td>
                            <td height="33" align="left">&nbsp;&nbsp;
                            <input name="qq" type="text" id="qq" class="input1" value="<?php echo $qq?>" maxlength="50" style="width:200px;" /></td>
                            <td height="33" align="left" class="bigtext" id="ckzfb"></td>
                          </tr>
                          <tr>
                            <td height="33" align="right">&nbsp;</td>
                            <td height="33" colspan="2" align="left">&nbsp;&nbsp;
                            <INPUT class=smtgray value=保存信息 type=submit></td>
                          </tr>
                        </table>
                      </form>
                      <style>
					  #binding table td{ border-left:#CCC 1px solid; border-bottom:#CCC 1px solid; height:30px; line-height:30px; text-align:center}
					  #binding table th{ border-left:#CCC 1px solid; border-bottom:#CCC 1px solid; height:30px; line-height:30px}
					  #binding table td .logo{background:url(../images/login_total.gif) no-repeat;width:25px; height:25px;float:left; }
					  #binding table td .name{ width:90px; margin-left:80px;float:left}
                      </style>
                      <form id="binding"  <?php if($current=='infoset'){?> style="display:none" <?php }?>>
                        <table style="TEXT-ALIGN: center; WIDTH: 450px; BORDER-COLLAPSE: collapse; border:#CCC 2px solid;" border="0" >
                        <tr>
    <th scope="col">网站</th>
    <th scope="col">状态</th>
    <th scope="col">操作</th>
    <?php if(QQLAPPON==1){?>
  <tr>
    <td><div class="name">QQ空间登陆：</div><div class="logo" style="background-position:0px -112px">&nbsp;</div></td>
    <?php if(in_array('QQ空间',$ortherwebname_arr)){?>
    <td>已绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('QQ空间')?>&act=del" onclick='return confirm("确定解除?")'>解除绑定</a></td>
    <?php }else{?>
    <td>未绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('QQ空间')?>&act=add">绑定账号</a></td>
    <?php }?>
  </tr>
  <?php }?>
  <?php if(QQAPPON==1){?>
  <tr>
    <td><div class="name">QQ微博登陆：</div><div class="logo" style="background-position:0px -51px">&nbsp;</div></td>
    <?php if(in_array('QQ微博',$ortherwebname_arr)){?>
    <td>已绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('QQ微博')?>&act=del" onclick='return confirm("确定解除?")'>解除绑定</a></td>
    <?php }else{?>
    <td>未绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('QQ微博')?>&act=add">绑定账号</a></td>
    <?php }?>
  </tr>
  <?php }?>
  <?php if(TAOAPPON==1){?>
  <tr>
    <td><div class="name">淘宝账号登陆：</div><div class="logo" style="background-position:0px 7px">&nbsp;</div></td>
    <?php if(in_array('淘宝',$ortherwebname_arr)){?>
    <td>已绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('淘宝')?>&act=del" onclick='return confirm("确定解除?")'>解除绑定</a></td>
    <?php }else{?>
    <td>未绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('淘宝')?>&act=add">绑定账号</a></td>
    <?php }?>
  </tr>
  <?php }?>
  <?php if(SINAAPPON==1){?>
  <tr>
    <td><div class="name">新浪微博登陆：</div><div class="logo" style="background-position:0px -24px">&nbsp;</div></td>
    <?php if(in_array('新浪微博',$ortherwebname_arr)){?>
    <td>已绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('新浪微博')?>&act=del" onclick='return confirm("确定解除?")'>解除绑定</a></td>
    <?php }else{?>
    <td>未绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('新浪微博')?>&act=add">绑定账号</a></td>
    <?php }?>
  </tr>
  <?php }?>
  <?php if(ALIPAYAPPON==1){?>
  <tr>
    <td><div class="name">支付宝登陆：</div><div class="logo" style="background-position:0px -82px">&nbsp;</div></td>
    <?php if(in_array('支付宝',$ortherwebname_arr)){?>
    <td>已绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('支付宝')?>&act=del" onclick='return confirm("确定解除?")'>解除绑定</a></td>
    <?php }else{?>
    <td>未绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('支付宝')?>&act=add">绑定账号</a></td>
    <?php }?>
  </tr>
  <?php }?>
  <?php if(KAIXINAPPON==1){?>
  <tr>
    <td><div class="name">开心网登陆：</div><div class="logo" style="background-position:0px -142px">&nbsp;</div></td>
    <?php if(in_array('开心网',$ortherwebname_arr)){?>
    <td><b style="color:#090">已绑定</b></td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('开心网')?>&act=del" onclick='return confirm("确定解除?")'>解除绑定</a></td>
    <?php }else{?>
    <td>未绑定</td>
    <td><a href="apilogin_do.php?ortherwebname=<?=urlencode('开心网')?>&act=add">绑定账号</a></td>
    <?php }?>
  </tr>
  <?php }?>
</table>
                      </form>
	</div>
	</div>
</div>
</div>
<?php
include("../template/".MOBAN."/footer.tpl.php");
mysql_close();
?>
</body>
</html>